package cn.com.nes.site.controller.demo;

import cn.com.nes.common.util.Globals;
import cn.com.nes.common.util.OssUtil;
import cn.com.nes.site.entity.PageData;
import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import java.io.UnsupportedEncodingException;
import java.util.HashMap;
import java.util.Map;

@Slf4j
@Controller
@RequestMapping("/v2/oss/demo")
public class OssDemoController {


    @RequestMapping(value = "/getImageWithWaterMark", method = RequestMethod.GET)
    @ResponseBody
    public PageData getImageWithWaterMark(@Param("imagePath") String imagePath) throws UnsupportedEncodingException {
        String path = OssUtil.getImgSignUrlWithWaterMark(imagePath, 3, Globals.bucketName, "清洁取暖工程管理");
        Map<String, Object> dataMap = new HashMap<>();
        dataMap.put("path", path);
        return PageData.ok(dataMap);
    }

}
